{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Audio Denoising Final(h).ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/HasikaR/Audio-Denoising-Deep-Learning/blob/main/Audio_Denoising_Final(h).ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "0XJvZjOK-qpk",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "cbed8d4e-50ec-4881-89a2-c3f824b0706d"
      },
      "source": [
        "from google.colab import drive\n",
        "drive.mount('/content/drive')"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Mounted at /content/drive\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "oIfDNUmfYPyA"
      },
      "source": [
        "import zipfile"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "t7mLVNHhYTIQ"
      },
      "source": [
        "with zipfile.ZipFile('/content/drive/MyDrive/s5.zip', 'r') as zip_ref:\n",
        "    zip_ref.extractall('/tmp')"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "CAST-3vDYXdm"
      },
      "source": [
        "with zipfile.ZipFile('/content/drive/MyDrive/c5.zip', 'r') as zip_ref:\n",
        "    zip_ref.extractall('/tmp2')"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "pe1IZKweLalI"
      },
      "source": [
        "'''\n",
        "with zipfile.ZipFile('/content/drive/MyDrive/s6.zip', 'r') as zip_ref:\n",
        "    zip_ref.extractall('/tmp3')\n",
        "\n",
        "'''"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "rhgczmxzLhJa"
      },
      "source": [
        "'''\n",
        "with zipfile.ZipFile('/content/drive/MyDrive/c6.zip', 'r') as zip_ref:\n",
        "    zip_ref.extractall('/tmp4')\n",
        "'''"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JtaJjYjA_sKf"
      },
      "source": [
        "import numpy as np\n",
        "from matplotlib import pyplot as plt\n",
        "import IPython.display as ipd\n",
        "import librosa\n",
        "import librosa.display\n",
        "from sklearn.model_selection import train_test_split\n",
        "from random import seed\n",
        "from random import randint\n",
        "from numpy import array\n",
        "from keras.models import Sequential\n",
        "from keras.layers import Dense\n",
        "from keras.layers import LSTM\n",
        "from math import sqrt\n",
        "from sklearn.metrics import mean_squared_error\n",
        "\n",
        "#load clean signal filenames\n",
        "files_path1='/tmp2/c5'\n",
        "c_files=librosa.util.find_files(files_path1, ext=['wav'])\n",
        "\n",
        "#load synthetic signal filenames\n",
        "files_path2='/tmp/s5'\n",
        "s_files=librosa.util.find_files(files_path2, ext=['wav'])\n",
        "\n",
        "#create a multicolumn object with synthetic and clean signal names\n",
        "c_arr=np.array(c_files)\n",
        "s_arr=np.array(s_files)\n",
        "samples= np.column_stack((c_arr,s_arr))\n",
        "samples=np.array(samples)\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "gC8KGuw4OLVQ"
      },
      "source": [
        "#split into train and test set\n",
        "train_samples,val_samples = train_test_split(samples,test_size=0.2)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "qQIOdJnnwacl",
        "outputId": "121d6b11-33f0-4e62-e932-8c6b6bc2c214"
      },
      "source": [
        "print(val_samples)"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "[['/tmp2/c5/ss181_cs7_01.wav' '/tmp/s5/ss181_cs7_kd1.wav']\n",
            " ['/tmp2/c5/ss2495_cs9_035.wav' '/tmp/s5/ss2495_cs9_tci5.wav']\n",
            " ['/tmp2/c5/ss4872_cs13_012.wav' '/tmp/s5/ss4872_cs13_vc12.wav']\n",
            " ['/tmp2/c5/ss92_cs4_02.wav' '/tmp/s5/ss92_cs4_kd2.wav']\n",
            " ['/tmp2/c5/ss10390_cs47_010.wav' '/tmp/s5/ss10390_cs47_r10.wav']\n",
            " ['/tmp2/c5/ss2512_cs9_052.wav' '/tmp/s5/ss2512_cs9_tci22.wav']\n",
            " ['/tmp2/c5/ss2516_cs9_056.wav' '/tmp/s5/ss2516_cs9_tci26.wav']\n",
            " ['/tmp2/c5/ss93_cs4_03.wav' '/tmp/s5/ss93_cs4_kd3.wav']\n",
            " ['/tmp2/c5/ss120_cs4_030.wav' '/tmp/s5/ss120_cs4_kd30.wav']\n",
            " ['/tmp2/c5/ss10344_cs45_084.wav' '/tmp/s5/ss10344_cs45_r24.wav']\n",
            " ['/tmp2/c5/ss73_cs3_013.wav' '/tmp/s5/ss73_cs3_kd13.wav']\n",
            " ['/tmp2/c5/ss189_cs7_09.wav' '/tmp/s5/ss189_cs7_kd9.wav']\n",
            " ['/tmp2/c5/ss173_cs6_083.wav' '/tmp/s5/ss173_cs6_kd23.wav']\n",
            " ['/tmp2/c5/ss2515_cs9_055.wav' '/tmp/s5/ss2515_cs9_tci25.wav']\n",
            " ['/tmp2/c5/ss117_cs4_027.wav' '/tmp/s5/ss117_cs4_kd27.wav']\n",
            " ['/tmp2/c5/ss2496_cs9_036.wav' '/tmp/s5/ss2496_cs9_tci6.wav']\n",
            " ['/tmp2/c5/ss7629_cs30_039.wav' '/tmp/s5/ss7629_cs30_acf9.wav']\n",
            " ['/tmp2/c5/ss7628_cs30_038.wav' '/tmp/s5/ss7628_cs30_acf8.wav']\n",
            " ['/tmp2/c5/ss10393_cs47_013.wav' '/tmp/s5/ss10393_cs47_r13.wav']\n",
            " ['/tmp2/c5/ss91_cs4_01.wav' '/tmp/s5/ss91_cs4_kd1.wav']\n",
            " ['/tmp2/c5/ss2574_cs11_0114.wav' '/tmp/s5/ss2574_cs11_tci24.wav']\n",
            " ['/tmp2/c5/ss10343_cs45_083.wav' '/tmp/s5/ss10343_cs45_r23.wav']\n",
            " ['/tmp2/c5/ss2485_cs8_025.wav' '/tmp/s5/ss2485_cs8_tci25.wav']\n",
            " ['/tmp2/c5/ss179_cs6_089.wav' '/tmp/s5/ss179_cs6_kd29.wav']\n",
            " ['/tmp2/c5/ss7724_cs33_014.wav' '/tmp/s5/ss7724_cs33_acf14.wav']\n",
            " ['/tmp2/c5/ss2472_cs8_012.wav' '/tmp/s5/ss2472_cs8_tci12.wav']\n",
            " ['/tmp2/c5/ss2552_cs11_092.wav' '/tmp/s5/ss2552_cs11_tci2.wav']\n",
            " ['/tmp2/c5/ss4966_cs16_0106.wav' '/tmp/s5/ss4966_cs16_vc16.wav']\n",
            " ['/tmp2/c5/ss160_cs6_070.wav' '/tmp/s5/ss160_cs6_kd10.wav']\n",
            " ['/tmp2/c5/ss2509_cs9_049.wav' '/tmp/s5/ss2509_cs9_tci19.wav']\n",
            " ['/tmp2/c5/ss10356_cs46_096.wav' '/tmp/s5/ss10356_cs46_r6.wav']\n",
            " ['/tmp2/c5/ss10268_cs43_08.wav' '/tmp/s5/ss10268_cs43_r8.wav']\n",
            " ['/tmp2/c5/ss2593_cs12_013.wav' '/tmp/s5/ss2593_cs12_tci13.wav']\n",
            " ['/tmp2/c5/ss148_cs5_058.wav' '/tmp/s5/ss148_cs5_kd28.wav']\n",
            " ['/tmp2/c5/ss2567_cs11_0107.wav' '/tmp/s5/ss2567_cs11_tci17.wav']\n",
            " ['/tmp2/c5/ss122_cs5_032.wav' '/tmp/s5/ss122_cs5_kd2.wav']\n",
            " ['/tmp2/c5/ss10398_cs47_018.wav' '/tmp/s5/ss10398_cs47_r18.wav']\n",
            " ['/tmp2/c5/ss7607_cs29_017.wav' '/tmp/s5/ss7607_cs29_acf17.wav']\n",
            " ['/tmp2/c5/ss4923_cs15_063.wav' '/tmp/s5/ss4923_cs15_vc3.wav']\n",
            " ['/tmp2/c5/ss4892_cs14_032.wav' '/tmp/s5/ss4892_cs14_vc2.wav']\n",
            " ['/tmp2/c5/ss10354_cs46_094.wav' '/tmp/s5/ss10354_cs46_r4.wav']\n",
            " ['/tmp2/c5/ss4925_cs15_065.wav' '/tmp/s5/ss4925_cs15_vc5.wav']\n",
            " ['/tmp2/c5/ss7711_cs33_01.wav' '/tmp/s5/ss7711_cs33_acf1.wav']\n",
            " ['/tmp2/c5/ss177_cs6_087.wav' '/tmp/s5/ss177_cs6_kd27.wav']\n",
            " ['/tmp2/c5/ss2575_cs11_0115.wav' '/tmp/s5/ss2575_cs11_tci25.wav']\n",
            " ['/tmp2/c5/ss4893_cs14_033.wav' '/tmp/s5/ss4893_cs14_vc3.wav']\n",
            " ['/tmp2/c5/ss76_cs3_016.wav' '/tmp/s5/ss76_cs3_kd16.wav']\n",
            " ['/tmp2/c5/ss4968_cs16_0108.wav' '/tmp/s5/ss4968_cs16_vc18.wav']\n",
            " ['/tmp2/c5/ss2517_cs9_057.wav' '/tmp/s5/ss2517_cs9_tci27.wav']\n",
            " ['/tmp2/c5/ss7713_cs33_03.wav' '/tmp/s5/ss7713_cs33_acf3.wav']\n",
            " ['/tmp2/c5/ss7660_cs31_070.wav' '/tmp/s5/ss7660_cs31_acf10.wav']\n",
            " ['/tmp2/c5/ss7596_cs29_06.wav' '/tmp/s5/ss7596_cs29_acf6.wav']\n",
            " ['/tmp2/c5/ss10367_cs46_0107.wav' '/tmp/s5/ss10367_cs46_r17.wav']\n",
            " ['/tmp2/c5/ss2590_cs12_010.wav' '/tmp/s5/ss2590_cs12_tci10.wav']\n",
            " ['/tmp2/c5/ss2579_cs11_0119.wav' '/tmp/s5/ss2579_cs11_tci29.wav']\n",
            " ['/tmp2/c5/ss2527_cs10_067.wav' '/tmp/s5/ss2527_cs10_tci7.wav']\n",
            " ['/tmp2/c5/ss4952_cs16_092.wav' '/tmp/s5/ss4952_cs16_vc2.wav']\n",
            " ['/tmp2/c5/ss4958_cs16_098.wav' '/tmp/s5/ss4958_cs16_vc8.wav']\n",
            " ['/tmp2/c5/ss2543_cs10_083.wav' '/tmp/s5/ss2543_cs10_tci23.wav']\n",
            " ['/tmp2/c5/ss10275_cs43_015.wav' '/tmp/s5/ss10275_cs43_r15.wav']\n",
            " ['/tmp2/c5/ss2549_cs10_089.wav' '/tmp/s5/ss2549_cs10_tci29.wav']\n",
            " ['/tmp2/c5/ss7631_cs30_041.wav' '/tmp/s5/ss7631_cs30_acf11.wav']\n",
            " ['/tmp2/c5/ss10267_cs43_07.wav' '/tmp/s5/ss10267_cs43_r7.wav']\n",
            " ['/tmp2/c5/ss184_cs7_04.wav' '/tmp/s5/ss184_cs7_kd4.wav']\n",
            " ['/tmp2/c5/ss4895_cs14_035.wav' '/tmp/s5/ss4895_cs14_vc5.wav']\n",
            " ['/tmp2/c5/ss4868_cs13_08.wav' '/tmp/s5/ss4868_cs13_vc8.wav']\n",
            " ['/tmp2/c5/ss10285_cs43_025.wav' '/tmp/s5/ss10285_cs43_r25.wav']\n",
            " ['/tmp2/c5/ss7635_cs30_045.wav' '/tmp/s5/ss7635_cs30_acf15.wav']\n",
            " ['/tmp2/c5/ss119_cs4_029.wav' '/tmp/s5/ss119_cs4_kd29.wav']\n",
            " ['/tmp2/c5/ss10306_cs44_046.wav' '/tmp/s5/ss10306_cs44_r16.wav']\n",
            " ['/tmp2/c5/ss7661_cs31_071.wav' '/tmp/s5/ss7661_cs31_acf11.wav']\n",
            " ['/tmp2/c5/ss2572_cs11_0112.wav' '/tmp/s5/ss2572_cs11_tci22.wav']\n",
            " ['/tmp2/c5/ss4862_cs13_02.wav' '/tmp/s5/ss4862_cs13_vc2.wav']\n",
            " ['/tmp2/c5/ss7612_cs29_022.wav' '/tmp/s5/ss7612_cs29_acf22.wav']\n",
            " ['/tmp2/c5/ss10378_cs46_0118.wav' '/tmp/s5/ss10378_cs46_r28.wav']\n",
            " ['/tmp2/c5/ss7637_cs30_047.wav' '/tmp/s5/ss7637_cs30_acf17.wav']\n",
            " ['/tmp2/c5/ss10311_cs44_051.wav' '/tmp/s5/ss10311_cs44_r21.wav']\n",
            " ['/tmp2/c5/ss2531_cs10_071.wav' '/tmp/s5/ss2531_cs10_tci11.wav']\n",
            " ['/tmp2/c5/ss4972_cs16_0112.wav' '/tmp/s5/ss4972_cs16_vc22.wav']\n",
            " ['/tmp2/c5/ss7644_cs30_054.wav' '/tmp/s5/ss7644_cs30_acf24.wav']\n",
            " ['/tmp2/c5/ss7673_cs31_083.wav' '/tmp/s5/ss7673_cs31_acf23.wav']\n",
            " ['/tmp2/c5/ss7692_cs32_0102.wav' '/tmp/s5/ss7692_cs32_acf12.wav']\n",
            " ['/tmp2/c5/ss140_cs5_050.wav' '/tmp/s5/ss140_cs5_kd20.wav']\n",
            " ['/tmp2/c5/ss126_cs5_036.wav' '/tmp/s5/ss126_cs5_kd6.wav']\n",
            " ['/tmp2/c5/ss10373_cs46_0113.wav' '/tmp/s5/ss10373_cs46_r23.wav']\n",
            " ['/tmp2/c5/ss4951_cs16_091.wav' '/tmp/s5/ss4951_cs16_vc1.wav']\n",
            " ['/tmp2/c5/ss7605_cs29_015.wav' '/tmp/s5/ss7605_cs29_acf15.wav']\n",
            " ['/tmp2/c5/ss4980_cs16_0120.wav' '/tmp/s5/ss4980_cs16_vc30.wav']\n",
            " ['/tmp2/c5/ss4992_cs17_012.wav' '/tmp/s5/ss4992_cs17_vc12.wav']\n",
            " ['/tmp2/c5/ss7732_cs33_022.wav' '/tmp/s5/ss7732_cs33_acf22.wav']\n",
            " ['/tmp2/c5/ss10353_cs46_093.wav' '/tmp/s5/ss10353_cs46_r3.wav']\n",
            " ['/tmp2/c5/ss10327_cs45_067.wav' '/tmp/s5/ss10327_cs45_r7.wav']\n",
            " ['/tmp2/c5/ss7672_cs31_082.wav' '/tmp/s5/ss7672_cs31_acf22.wav']\n",
            " ['/tmp2/c5/ss175_cs6_085.wav' '/tmp/s5/ss175_cs6_kd25.wav']\n",
            " ['/tmp2/c5/ss10368_cs46_0108.wav' '/tmp/s5/ss10368_cs46_r18.wav']\n",
            " ['/tmp2/c5/ss2551_cs11_091.wav' '/tmp/s5/ss2551_cs11_tci1.wav']\n",
            " ['/tmp2/c5/ss2594_cs12_014.wav' '/tmp/s5/ss2594_cs12_tci14.wav']\n",
            " ['/tmp2/c5/ss10388_cs47_08.wav' '/tmp/s5/ss10388_cs47_r8.wav']\n",
            " ['/tmp2/c5/ss7693_cs32_0103.wav' '/tmp/s5/ss7693_cs32_acf13.wav']\n",
            " ['/tmp2/c5/ss2559_cs11_099.wav' '/tmp/s5/ss2559_cs11_tci9.wav']\n",
            " ['/tmp2/c5/ss168_cs6_078.wav' '/tmp/s5/ss168_cs6_kd18.wav']\n",
            " ['/tmp2/c5/ss158_cs6_068.wav' '/tmp/s5/ss158_cs6_kd8.wav']\n",
            " ['/tmp2/c5/ss10316_cs44_056.wav' '/tmp/s5/ss10316_cs44_r26.wav']\n",
            " ['/tmp2/c5/ss7622_cs30_032.wav' '/tmp/s5/ss7622_cs30_acf2.wav']\n",
            " ['/tmp2/c5/ss65_cs3_05.wav' '/tmp/s5/ss65_cs3_kd5.wav']\n",
            " ['/tmp2/c5/ss7601_cs29_011.wav' '/tmp/s5/ss7601_cs29_acf11.wav']\n",
            " ['/tmp2/c5/ss5002_cs17_022.wav' '/tmp/s5/ss5002_cs17_vc22.wav']\n",
            " ['/tmp2/c5/ss4871_cs13_011.wav' '/tmp/s5/ss4871_cs13_vc11.wav']\n",
            " ['/tmp2/c5/ss10371_cs46_0111.wav' '/tmp/s5/ss10371_cs46_r21.wav']\n",
            " ['/tmp2/c5/ss2499_cs9_039.wav' '/tmp/s5/ss2499_cs9_tci9.wav']\n",
            " ['/tmp2/c5/ss2530_cs10_070.wav' '/tmp/s5/ss2530_cs10_tci10.wav']\n",
            " ['/tmp2/c5/ss170_cs6_080.wav' '/tmp/s5/ss170_cs6_kd20.wav']\n",
            " ['/tmp2/c5/ss2565_cs11_0105.wav' '/tmp/s5/ss2565_cs11_tci15.wav']\n",
            " ['/tmp2/c5/ss4940_cs15_080.wav' '/tmp/s5/ss4940_cs15_vc20.wav']\n",
            " ['/tmp2/c5/ss2564_cs11_0104.wav' '/tmp/s5/ss2564_cs11_tci14.wav']\n",
            " ['/tmp2/c5/ss10396_cs47_016.wav' '/tmp/s5/ss10396_cs47_r16.wav']\n",
            " ['/tmp2/c5/ss10375_cs46_0115.wav' '/tmp/s5/ss10375_cs46_r25.wav']\n",
            " ['/tmp2/c5/ss7665_cs31_075.wav' '/tmp/s5/ss7665_cs31_acf15.wav']\n",
            " ['/tmp2/c5/ss2540_cs10_080.wav' '/tmp/s5/ss2540_cs10_tci20.wav']\n",
            " ['/tmp2/c5/ss7655_cs31_065.wav' '/tmp/s5/ss7655_cs31_acf5.wav']\n",
            " ['/tmp2/c5/ss2488_cs8_028.wav' '/tmp/s5/ss2488_cs8_tci28.wav']\n",
            " ['/tmp2/c5/ss88_cs3_028.wav' '/tmp/s5/ss88_cs3_kd28.wav']\n",
            " ['/tmp2/c5/ss4979_cs16_0119.wav' '/tmp/s5/ss4979_cs16_vc29.wav']\n",
            " ['/tmp2/c5/ss4927_cs15_067.wav' '/tmp/s5/ss4927_cs15_vc7.wav']\n",
            " ['/tmp2/c5/ss2604_cs12_024.wav' '/tmp/s5/ss2604_cs12_tci24.wav']\n",
            " ['/tmp2/c5/ss2562_cs11_0102.wav' '/tmp/s5/ss2562_cs11_tci12.wav']\n",
            " ['/tmp2/c5/ss4963_cs16_0103.wav' '/tmp/s5/ss4963_cs16_vc13.wav']\n",
            " ['/tmp2/c5/ss7683_cs32_093.wav' '/tmp/s5/ss7683_cs32_acf3.wav']\n",
            " ['/tmp2/c5/ss7708_cs32_0118.wav' '/tmp/s5/ss7708_cs32_acf28.wav']\n",
            " ['/tmp2/c5/ss109_cs4_019.wav' '/tmp/s5/ss109_cs4_kd19.wav']\n",
            " ['/tmp2/c5/ss4978_cs16_0118.wav' '/tmp/s5/ss4978_cs16_vc28.wav']\n",
            " ['/tmp2/c5/ss4931_cs15_071.wav' '/tmp/s5/ss4931_cs15_vc11.wav']\n",
            " ['/tmp2/c5/ss10279_cs43_019.wav' '/tmp/s5/ss10279_cs43_r19.wav']\n",
            " ['/tmp2/c5/ss2469_cs8_09.wav' '/tmp/s5/ss2469_cs8_tci9.wav']\n",
            " ['/tmp2/c5/ss64_cs3_04.wav' '/tmp/s5/ss64_cs3_kd4.wav']\n",
            " ['/tmp2/c5/ss7599_cs29_09.wav' '/tmp/s5/ss7599_cs29_acf9.wav']\n",
            " ['/tmp2/c5/ss7670_cs31_080.wav' '/tmp/s5/ss7670_cs31_acf20.wav']\n",
            " ['/tmp2/c5/ss108_cs4_018.wav' '/tmp/s5/ss108_cs4_kd18.wav']\n",
            " ['/tmp2/c5/ss2554_cs11_094.wav' '/tmp/s5/ss2554_cs11_tci4.wav']\n",
            " ['/tmp2/c5/ss4917_cs14_057.wav' '/tmp/s5/ss4917_cs14_vc27.wav']\n",
            " ['/tmp2/c5/ss7722_cs33_012.wav' '/tmp/s5/ss7722_cs33_acf12.wav']\n",
            " ['/tmp2/c5/ss4935_cs15_075.wav' '/tmp/s5/ss4935_cs15_vc15.wav']\n",
            " ['/tmp2/c5/ss10372_cs46_0112.wav' '/tmp/s5/ss10372_cs46_r22.wav']\n",
            " ['/tmp2/c5/ss116_cs4_026.wav' '/tmp/s5/ss116_cs4_kd26.wav']]\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "dArAnhk7LvJj"
      },
      "source": [
        "'''\n",
        "#test samples\n",
        "#load clean signal filenames\n",
        "files_path3='/tmp4/c6'\n",
        "tc_files=librosa.util.find_files(files_path3, ext=['wav'])\n",
        "\n",
        "#load synthetic signal filenames\n",
        "files_path4='/tmp3/s6'\n",
        "ts_files=librosa.util.find_files(files_path4, ext=['wav'])\n",
        "\n",
        "#create a multicolumn object with synthetic and clean signal names\n",
        "tc1_arr=np.array(tc_files)\n",
        "ts1_arr=np.array(ts_files)\n",
        "t_samples= np.column_stack((tc1_arr,ts1_arr))\n",
        "test_samples=np.array(t_samples)\n",
        "'''"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "twg2xRtAAuHa",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "0099da58-d290-4f0b-8545-a31e6c9cf9f4"
      },
      "source": [
        "#number of samples in train and test set\n",
        "print(len(train_samples))\n",
        "#print(len(test_samples))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "576\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "vb1ja7faBb-H",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "594312d3-572f-4b3c-b2f3-e58da24b85dd"
      },
      "source": [
        "#install pydub for audio slicing\n",
        "!pip install pydub"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Collecting pydub\n",
            "  Downloading https://files.pythonhosted.org/packages/a6/53/d78dc063216e62fc55f6b2eebb447f6a4b0a59f55c8406376f76bf959b08/pydub-0.25.1-py2.py3-none-any.whl\n",
            "Installing collected packages: pydub\n",
            "Successfully installed pydub-0.25.1\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Rl2rhNNVBUGR"
      },
      "source": [
        "from pydub import AudioSegment\n",
        "from pydub.utils import make_chunks\n",
        "sig_slice = []\n",
        "def audio_slicer(file_name):\n",
        "    myaudio = AudioSegment.from_file(file_name , \"wav\") \n",
        "    chunk_length_ms = 12000 # pydub calculates in millisec\n",
        "    chunks = make_chunks(myaudio, chunk_length_ms) #Make chunks of one sec\n",
        "        \n",
        "    #Export all of the individual chunks as wav files\n",
        "    for i, chunk in enumerate(chunks):\n",
        "        chunk_name = \"chunk{0}.wav\".format(i)\n",
        "        chunk.export(chunk_name, format=\"wav\")\n",
        "        data,sr = librosa.load(chunk_name, sr=None)\n",
        "        sig_slice.append(data)\n",
        "    return sig_slice"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Z1uPUX57BDY8"
      },
      "source": [
        "def generator(samples, batch_size):\n",
        "  num_samples = len(samples)\n",
        "  while True:\n",
        "      for offset in range(0, num_samples, batch_size):\n",
        "            # Get the samples you'll use in this batch\n",
        "            batch_samples = samples[offset:offset+batch_size]\n",
        " \n",
        "            # Initialise X_train and y_train arrays for this batch\n",
        "            X_train = []\n",
        "            y_train = []\n",
        "            count = 0\n",
        "\n",
        "            # For each example\n",
        "            for _ in batch_samples:\n",
        "                # Load image (X)\n",
        "                i=0;\n",
        "                count += 12\n",
        "                syn_filename = samples[i][0]\n",
        "                sliced_syn_signal = audio_slicer(syn_filename)\n",
        "                        \n",
        "                X_train.append(sliced_syn_signal)\n",
        "                # Read label (y)\n",
        "               \n",
        "                clean_filename = samples[i][1]\n",
        "                sliced_cln_signal = audio_slicer(syn_filename)\n",
        "                y_train.append(sliced_cln_signal)\n",
        "                \n",
        "                if count >= batch_size:\n",
        "                    # Make sure they're numpy arrays (as opposed to lists)\n",
        "                    X_train = np.asarray(X_train)\n",
        "                    #X_train = X_train.reshape(1,48000,1)\n",
        "                    y_train = np.array(y_train)\n",
        "                    #y_train = y_train.reshape(1,48000,1)\n",
        "                    #print(X_train.shape)\n",
        "                    #print(y_train.shape)\n",
        "                    # The generator-y part: yield the next training batch            \n",
        "                    yield X_train, y_train\n",
        "\n",
        "                    #clear data \n",
        "                    X_train = []\n",
        "                    y_train = []\n",
        "                    count = 0"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "aOV6GJGtCxo8"
      },
      "source": [
        "\n",
        "#call to generator for training and test samples\n",
        "train_generator = generator(train_samples, batch_size=36)\n",
        "val_generator = generator(val_samples, batch_size=36)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "aaozJtVuQ5T8"
      },
      "source": [
        "#test_generator = generator(test_samples, batch_size=36)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "wDtnif027fSB"
      },
      "source": [
        "import keras"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "GFE9t2ri4AmD"
      },
      "source": [
        "class LossHistory(keras.callbacks.Callback):\n",
        "    def on_train_begin(self, logs={}):\n",
        "        self.losses = []\n",
        "    \n",
        "    def on_yeild(self, batch, logs={}):\n",
        "      self.losses.append(logs.get('loss'))\n",
        "\n",
        "    def on_batch_end(self, batch, logs={}):\n",
        "        self.losses.append(logs.get('loss'))\n",
        "\n",
        "    def on_epoch_end(self, epoch, logs={}):\n",
        "        self.losses.append(logs.get('loss'))\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "3BuNQKDn4Dxw"
      },
      "source": [
        "import tensorflow as tf\n",
        "import gc\n",
        "\n",
        "class MyCustomCallback(tf.keras.callbacks.Callback):\n",
        "    def on_epoch_end(self, epoch, logs=None):\n",
        "        gc.collect()\n",
        "        keras.backend.clear_session()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "iC_3mPhSDPms"
      },
      "source": [
        "from keras.callbacks import EarlyStopping, ModelCheckpoint\n",
        "from keras.layers import TimeDistributed\n",
        "\n",
        "n_epoch = 1 \n",
        "# create LSTM\n",
        "model = Sequential()\n",
        "model.add(LSTM(16, input_shape= (None, 529200),return_sequences=True))\n",
        "model.add(TimeDistributed(Dense(529200)))\n",
        "model.compile(loss='mean_squared_error', optimizer='adam')\n",
        "mycall = [EarlyStopping(monitor='loss', min_delta=0.001, patience=1, mode='min', verbose=1),ModelCheckpoint(filepath=\"/content/drive/MyDrive/weights.hdf5\", monitor = 'loss', verbose=1, save_best_only=True,mode='min', save_freq = 1),MyCustomCallback(), LossHistory()]"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "96juPTbIDzc2",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "a07dfbe8-69af-4973-d9bd-f8645b48ee29"
      },
      "source": [
        "model.summary()"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Model: \"sequential\"\n",
            "_________________________________________________________________\n",
            "Layer (type)                 Output Shape              Param #   \n",
            "=================================================================\n",
            "lstm (LSTM)                  (None, None, 16)          33869888  \n",
            "_________________________________________________________________\n",
            "time_distributed (TimeDistri (None, None, 529200)      8996400   \n",
            "=================================================================\n",
            "Total params: 42,866,288\n",
            "Trainable params: 42,866,288\n",
            "Non-trainable params: 0\n",
            "_________________________________________________________________\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "PouLvWL_DymV",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "fda466f4-3b2d-489a-cb75-4196d8e9b2ef"
      },
      "source": [
        "history_callback=model.fit(train_generator,\n",
        "          steps_per_epoch =len(train_samples)//36,\n",
        "          epochs = 1,\n",
        "          validation_data = val_generator,\n",
        "          validation_steps = len(val_samples)//36, callbacks = mycall)"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "\r 1/16 [>.............................] - ETA: 1:03 - loss: 0.0118\n",
            "Epoch 00001: loss improved from inf to 0.01178, saving model to /content/drive/MyDrive/weights.hdf5\n",
            " 2/16 [==>...........................] - ETA: 1:53 - loss: 0.0118\n",
            "Epoch 00001: loss improved from 0.01178 to 0.01177, saving model to /content/drive/MyDrive/weights.hdf5\n",
            " 3/16 [====>.........................] - ETA: 1:21 - loss: 0.0118\n",
            "Epoch 00001: loss improved from 0.01177 to 0.01175, saving model to /content/drive/MyDrive/weights.hdf5\n",
            " 4/16 [======>.......................] - ETA: 1:11 - loss: 0.0118\n",
            "Epoch 00001: loss improved from 0.01175 to 0.01173, saving model to /content/drive/MyDrive/weights.hdf5\n",
            " 5/16 [========>.....................] - ETA: 1:09 - loss: 0.0117\n",
            "Epoch 00001: loss improved from 0.01173 to 0.01169, saving model to /content/drive/MyDrive/weights.hdf5\n",
            " 6/16 [==========>...................] - ETA: 1:09 - loss: 0.0117\n",
            "Epoch 00001: loss improved from 0.01169 to 0.01163, saving model to /content/drive/MyDrive/weights.hdf5\n",
            "WARNING:tensorflow:Callback method `on_train_batch_end` is slow compared to the batch time (batch time: 2.9876s vs `on_train_batch_end` time: 4.0737s). Check your callbacks.\n",
            " 7/16 [============>.................] - ETA: 1:08 - loss: 0.0117\n",
            "Epoch 00001: loss improved from 0.01163 to 0.01155, saving model to /content/drive/MyDrive/weights.hdf5\n",
            " 8/16 [==============>...............] - ETA: 1:02 - loss: 0.0117\n",
            "Epoch 00001: loss improved from 0.01155 to 0.01146, saving model to /content/drive/MyDrive/weights.hdf5\n",
            " 9/16 [===============>..............] - ETA: 54s - loss: 0.0116 \n",
            "Epoch 00001: loss improved from 0.01146 to 0.01135, saving model to /content/drive/MyDrive/weights.hdf5\n",
            "10/16 [=================>............] - ETA: 48s - loss: 0.0116\n",
            "Epoch 00001: loss improved from 0.01135 to 0.01124, saving model to /content/drive/MyDrive/weights.hdf5\n",
            "11/16 [===================>..........] - ETA: 41s - loss: 0.0115\n",
            "Epoch 00001: loss improved from 0.01124 to 0.01111, saving model to /content/drive/MyDrive/weights.hdf5\n",
            "12/16 [=====================>........] - ETA: 33s - loss: 0.0115\n",
            "Epoch 00001: loss improved from 0.01111 to 0.01097, saving model to /content/drive/MyDrive/weights.hdf5\n",
            "13/16 [=======================>......] - ETA: 26s - loss: 0.0114\n",
            "Epoch 00001: loss improved from 0.01097 to 0.01083, saving model to /content/drive/MyDrive/weights.hdf5\n",
            "14/16 [=========================>....] - ETA: 18s - loss: 0.0114\n",
            "Epoch 00001: loss improved from 0.01083 to 0.01068, saving model to /content/drive/MyDrive/weights.hdf5\n",
            "15/16 [===========================>..] - ETA: 9s - loss: 0.0113 \n",
            "Epoch 00001: loss improved from 0.01068 to 0.01052, saving model to /content/drive/MyDrive/weights.hdf5\n",
            "16/16 [==============================] - ETA: 0s - loss: 0.0113\n",
            "Epoch 00001: loss improved from 0.01052 to 0.01036, saving model to /content/drive/MyDrive/weights.hdf5\n",
            "16/16 [==============================] - 186s 12s/step - loss: 0.0112 - val_loss: 0.0091\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "AcQku96q9TS9",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "b0889174-b018-46b1-bdda-22ff84cc81e4"
      },
      "source": [
        "history_callback"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<tensorflow.python.keras.callbacks.History at 0x7f7c7ef7af90>"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 19
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ICIkTjDS90ak",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 295
        },
        "outputId": "ac799301-7796-4bea-abaf-50fa5a1c799c"
      },
      "source": [
        "plt.plot(history_callback.history['loss'],'ro')\n",
        "plt.plot(history_callback.history['val_loss'],'ro')\n",
        "plt.title('model loss')\n",
        "plt.ylabel('loss')\n",
        "plt.xlabel('epoch')\n",
        "plt.legend(['train', 'test'], loc='upper left')\n",
        "plt.show()"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZQAAAEWC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blrwLj0r5NZOssAFOB76fAWANckso/A/xA0nWpj/PbcRpmLeK7DZt1AEmvRMShHT0Oszz5lJeZmeXCRyhmZpYLH6GYmVkuHChmZpYLB4qZmeXCgWJmZrlwoJiZWS7+P7Ng3Qi8B6LpAAAAAElFTkSuQmCC\n",
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {
            "tags": [],
            "needs_background": "light"
          }
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "elDXeOt0yyCg",
        "outputId": "a6408f9f-a8ab-446c-c9f7-b103a3a18b87"
      },
      "source": [
        "print(history_callback.history['loss'])"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "[0.006902376655489206]\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6s8BEcmKGH_w",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "d74cf16f-ad60-4e65-eab3-2f64680a893a"
      },
      "source": [
        "#save model to disk\n",
        "from tensorflow.keras.models import save_model\n",
        "model_json = model.to_json()\n",
        "with open(\"/content/drive/MyDrive/model.json\", \"w\") as json_file:\n",
        "    json_file.write(model_json)\n",
        "    \n",
        "model.save_weights(\"/content/drive/MyDrive/model.h5\")\n",
        "print(\"Saved model to disk\")"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Saved model to disk\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "LM67QdU08r-V",
        "outputId": "b2989059-7a76-4712-e914-e5736f994ff1"
      },
      "source": [
        "print(history_callback.history['loss'])"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "[0.010361848399043083]\n"
          ],
          "name": "stdout"
        }
      ]
    }
  ]
}